package com.zzyweb.managementsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zzyweb.managementsystem.mapper.BuildingMapper;
import com.zzyweb.managementsystem.pojo.Building;
import com.zzyweb.managementsystem.service.BuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhiyi
 * @date 9/23/25
 **/
@Service
public class BuildingServiceImpl implements BuildingService {
    @Autowired
    BuildingMapper buildingMapper;
    @Override
    public List<Building> getAllBuildings() {
        return buildingMapper.selectList(null);
    }

    @Override
    public List<Building> getBuildingByConditions(Building building) {
        QueryWrapper<Building> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(building.getNumber()!=null && !building.getNumber().trim().isEmpty(),"number", building.getNumber())
                .eq(building.getUnit() != null && !building.getUnit().trim().isEmpty(), "unit", building.getUnit());
        return buildingMapper.selectList(queryWrapper);
    }
}
